package com.wjd.wshow.controller;

import com.wjd.wshow.bean.CatalogSearchBean;
import com.wjd.wshow.entity.Catalog;
import com.wjd.wshow.service.CatalogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@ResponseBody
@RequestMapping("/catalogs")
@RestController("CatalogController")
public class CatalogController {

    private static Logger logger = LoggerFactory.getLogger(CatalogController.class);

    @javax.annotation.Resource(name = "CatalogService")
    private CatalogService catalogService;

    /**
     * 查找指定节点下的目录节点
     * @param id 指定节点id，null表示根节点
     * @param search 查找内容
     * @return 得到的资源节点
     */
    @PostMapping(value = {"/", "/{id}"})
    public List<Catalog> listCatalogs(@PathVariable(required = false) String id, @RequestBody CatalogSearchBean search) {
        List<Catalog> catalogs;
        catalogs = catalogService.getChildren(id);
        return catalogs;
    }

}
